<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //回文字符串
        let a = "abcba";
        let b = a.split("").reverse().join("");
        console.log(a == b);
        // 回文数字
        let my = 123321
        //  1.先将数字转成字符串A，再经过变成数组，数组反转，数组变成字符串B三步操作之后，比较字符串A和B，得出结论
        // let my1 = my + ''
        // Array.from(my1).reverse().join('')
        // console.log(my == my1);
        // 2.将数字转换成字符串A，从后往前循环字符串A，将循环出来的字符拼接成新的字符串B，比较字符串A和B，得出结论
        // let my1 = my+ ''
        // let newStr = ''
        // for (let len = my1.length, i = len - 1; i >= 0; i--) {
        //     newStr += my1[i]
        // }
        // console.log(newStr === my1);
        // 3.以中间数为节点，判断左右两边首尾是否相等
         if (my< 0 || (my !== 0 && my % 10 === 0)) {
               console.log(false);
            } else if (0 <= my && my < 10) {
                console.log(true);
            }
            my = '' + my
            for (let i = 0; i < my.length / 2; i++) {
                if (my[i] !== my[my.length - i - 1]) {
                     console.log(false);
                }
            }
             console.log(true);
    </script>
</body>

</html>